from rest_framework import serializers
import datetime
from .models import Book, Borrowed


# 书店信息序列化
class BooksSerializer(serializers.ModelSerializer):
    add_date = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)

    class Meta:
        model = Book
        fields = '__all__'
        read_only_fields = ['id']


# 书店信息序列化
class BorrowedSerializer(serializers.ModelSerializer):
    borrow_date = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = Borrowed
        fields = '__all__'
        read_only_fields = ['id']
